
struct Seconds(i32);

#[derive(PartialEq, PartialOrd)]
struct Centimeters(f64);

#[derive(Debug)]
struct Inches(i32);
impl Inches {
    fn to_centimeters(&self) -> Centimeters {
        //NOTE: destruct the Struct(type) tuple 's value as ref
        let &Inches(inches) = self;

        Centimeters((inches as f64) * 2.54)
    }
}


pub fn main(){
    println!("hello traits::derives");

    let one_second = Seconds(1);
    //Compile Error:  need to impl trait Debug
    //println!("One Second look like: {:?}", one_second);
    //
    //Compile Error: Seconds can't be compared, it don't impl the PartialEq trait
    //let _this_is_true = (one_second == one_second);
    
    //NOTE: destruct the Struct(type) tuple 's value
    let Seconds(sec) = one_second; // copy, not move
    println!("One Second look like: {:?}", sec);


    let foot = Inches(12);
    println!("One foot equals {:?}", foot);
    
    let meter = Centimeters(100.0);
    
    let cmp = 
        if foot.to_centimeters() < meter {
            "smaller"
        }
        else  {
            "bigger"
        };
    println!("One foot is {} than one meter.", cmp);

}
